# 中枢集群的名称
export HUB_CLUSTER_NAME="hub" # export HUB_CLUSTER_NAME=hub
# 托管集群的名称
export MANAGED_CLUSTER_NAME="cluster1" # export MANAGED_CLUSTER_NAME=cluster1
# 中枢集群在你的KubeConfig中的Context名称
export CTX_HUB_CLUSTER="k3d-hub" # export CTX_HUB_CLUSTER=kind-hub
# 托管集群在你的KubeConfig中的Context名称
export CTX_MANAGED_CLUSTER="k3d-cluster1" # export CTX_MANAGED_CLUSTER=kind-cluster1
export token_data="790313"
export api_port="41783"
export hub_apiserver="https://0.0.0.0:$api_port"
# export config='kind.yaml'
# # 创建中枢集群
# kind create cluster --name $HUB_CLUSTER_NAME --config $config
# # 创建托管集群
# kind create cluster --name $MANAGED_CLUSTER_NAME --config $config
# k3d cluster create $HUB_CLUSTER_NAME --api-port $api_port
# k3d cluster create $MANAGED_CLUSTER_NAME --api-port $api_port
export KUBECONFIG=$HOME/.kube/config
touch /mnt/c/Users/Administrator/AppData/Roaming/Lens/kubeconfigs/k3d-dev
cat $HOME/.kube/config >/mnt/c/Users/Administrator/AppData/Roaming/Lens/kubeconfigs/k3d-dev
clusteradm init --context $CTX_HUB_CLUSTER

# clusteradm join --hub-token $token_data --hub-apiserver $hub_apiserver --cluster-name k3d-cluster1

clusteradm join --context $CTX_MANAGED_CLUSTER --hub-token $token_data --hub-apiserver $hub_apiserver --cluster-name $MANAGED_CLUSTER_NAME

kubectl get csr -w --context $CTX_HUB_CLUSTER | grep $MANAGED_CLUSTER_NAME
